;
;	>> PigXLs - Stage 1<<
;
;	A 128 bytes intro for the Atari 800 XL (c) 2010-09-11 by JAC!
;	Stage 1: Hires mode with index addressing,  color based on index
;
;	Created using WUDSN IDE. Visit http://www.wudsn.com to increase my hit counter.

;	IOCB commands
open	= $03
close	= $0c
plot	= $09
draw	= $11
fill	= $12

iocom	= $342	;Command
ioadr	= $344	;Address
icaux1	= $034A	;Auxilary 1
icaux2	= $034B	;Auxilary 2
ciov	= $e456	;CIO vector

rowcrs	= $54	;Row of cursor, 1 byte
colcrs	= $55	;Column of cursor, 2 bytes

color	= $2fb	;Color for graphics operations

*	= $2000

start	ldx #$60	;Channel 6
	lda #open	;Set open command
	sta iocom,x
;	lda #<screen	;ioadr,x points to $00 after startup
;	sta ioadr,x
;	lda #>screen
;	sta ioadr+1,x
	lda #'S		;Instead of string definition "S:",$9B
 	sta $00
	lda #8		;Graphics 8, $10 is ignored
	sta icaux2,x	;icaus1,x is already 0

loop 	jsr ciov	;Leaves a and x unchanged, returns y=1
dodraw 	lda #draw	;Set draw command
	sta iocom,x
count	ldy #0
	bne nofirst	;Leave color black for first line starting at (0,0)
	tya
nofirst	sta color
	inc count+1 
 	lda pigx,y	;Random column
	sta colcrs
 	lda pigy,y
 	sta rowcrs
stop	bne loop

effloop
	ldx 20
effloopx
	txa
	and #31
	cmp #16
	bcc *+4
	eor #31

	sta $d40a
	sta $d017

	lda $d40b
	beq effloop
	asl
	bpl *+4
	eor #$ff
	sta $d018
	inx
	bvc effloopx
end

xoffset	= 27
yoffset = 0

pigx	.byte [48-xoffset],[45-xoffset], [67-xoffset], [184-xoffset], [194-xoffset]
	.byte [208-xoffset], [226-xoffset], [233-xoffset], [252-xoffset], [282-xoffset]
	.byte [234-xoffset], [158-xoffset], [139-xoffset], [147-xoffset], [136-xoffset]
	.byte [86-xoffset], [117-xoffset], [108-xoffset], [71-xoffset], [48-xoffset]
pigy	.byte [88-yoffset], [135-yoffset], [125-yoffset], [157-yoffset], [177-yoffset]
	.byte [181-yoffset], [157-yoffset], [171-yoffset], [175-yoffset], [107-yoffset]
	.byte [39-yoffset], [57-yoffset], [43-yoffset], [63-yoffset], [71-yoffset]
	.byte [51-yoffset], [77-yoffset], [91-yoffset], [105-yoffset], [93-yoffset]

